package com.example.content.viewmodule.login

import com.example.content.repository.RepositoryMgr
import com.example.content.viewmodule.BaseViewModel
import com.example.content.viewmodule.viewdata.CommonViewState
import com.example.core.livedata.SingleLiveEvent
import com.example.core.network.HttpClient

/**
 * Created by zhudongao
 * Desc
 * Date 2020/10/25
 */
class LoginViewModel : BaseViewModel<CommonViewState>() {

    val loginResult = SingleLiveEvent<Boolean>()

    fun login(phoneNumber: String, verifyCode: String) {
        launch(
            block = {
                val userToken = RepositoryMgr.login(phoneNumber, verifyCode)
                userToken?.let { TokenStore.setUserToken(it) }
                loginResult.value = true
            }
        )
    }
}